import { createApp } from 'vue'
import { createPinia } from 'pinia'
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/reset.css'

import App from './App.vue'
import router from './router'

import './assets/main.css'

const app = createApp(App)

app.use(createPinia())
app.use(router)
app.use(Antd)

// 全局权限指令
app.directive('permission', {
  mounted(el, binding) {
    const { value } = binding
    // 引入权限验证函数
    import('@/utils/permission').then(module => {
      const { hasPermission } = module
      if (value && !hasPermission(value)) {
        el.parentNode?.removeChild(el)
      }
    })
  }
})

app.mount('#app')